﻿namespace Agile.Service.Admin.Model;

public partial class SysAdvModel
{
    protected override async Task<string> ToLogAsync(BaseModel newBaseModel, BaseModel oldBaseModel, IServiceProvider serviceProvider)
    {
        var newModel = (SysAdvModel)newBaseModel;
        var oldModel = (SysAdvModel)oldBaseModel;

        var logBuilder = new LogContentBuilder();
        if (newModel.IsChanged(nameof(AdvTitle)))
        {
            logBuilder.Append("广告标题".ToLog(oldModel.AdvTitle, newModel.AdvTitle));
        }
        if (newModel.IsChanged(nameof(IsDeleted)))
        {
            logBuilder.Append("是否删除".ToLog(oldModel.IsDeleted ? "是" : "否", newModel.IsDeleted ? "是" : "否"));
        }
        if (newModel.IsChanged(nameof(EffectiveTime)))
        {
            logBuilder.Append("生效时间".ToLog(oldModel.EffectiveTime, newModel.EffectiveTime));
        }
        if (newModel.IsChanged(nameof(FailureTime)))
        {
            logBuilder.Append("失效时间".ToLog(oldModel.FailureTime, newModel.FailureTime));
        }
        if (newModel.IsChanged(nameof(IsPublish)))
        {
            logBuilder.Append("是否发布".ToLog(oldModel.IsPublish ? "是" : "否", newModel.IsPublish ? "是" : "否"));
        }
        if (newModel.IsChanged(nameof(JumpUrl)))
        {
            logBuilder.Append("跳转地址".ToLog(oldModel.JumpUrl, newModel.JumpUrl));
        }
        if (newModel.IsChanged(nameof(Remark)))
        {
            logBuilder.Append("备注".ToLog(oldModel.Remark, newModel.Remark));
        }
        await Task.CompletedTask;
        return logBuilder.ToString();
    }
}
